package com.itheima.Controller;

import com.itheima.DTO.OrderDTO;
import com.itheima.Service.OrderService;
import com.itheima.VO.OrderVO;
import com.itheima.common.entity.Result;
import com.itheima.common.utils.DateUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/order")
@Slf4j
@Api(tags = "体检预约")
public class OrderController {

    @Autowired
    private OrderService orderService;

    @PostMapping("/findById")
    @ApiOperation("根据预约id查询预约信息")
    public Result getOrderById(@RequestParam String id){
        OrderVO orderVO = orderService.getOrderById(Integer.parseInt(id));
        return new Result(true,"查询成功",orderVO);
    }

    @PostMapping("/submitOrder")
    @ApiOperation("体检预约")
    public Result submitOrder(@RequestBody OrderDTO orderDTO) throws Exception{
        log.info("预约信息：{}",orderDTO);
        Integer id =  orderService.submitOrder(orderDTO);
        return new Result(true,"预约成功",id);
    }


}
